> < ^ Date: Fri, 13 May 1994 11:53:00 +0100
> < ^ From: Sebastian Egner <sebastian.egner@philips.com >
^ Subject: [Mathematica/GAP-syntax interface]

Hallo GAP-world!

I wrote a Mathematica/GAP-syntax interface which I have
posted into ftp.math.rwth-aachen.de:/pub/incoming.
It contains the files gapmath.doc, gap.m, math.g.
The file gapmath.doc copied below:

GAP/Mathematica-Interface
=========================

Sebastian Egner (egner@zkm.de), 13. May 1994
in GAP v3.3, Mathematica v2.0 on IBM-PC, SGI Iris, Sun Sparc.

files:
  gapmath.doc --- this file, general information
  math.g      --- a GAP-library extension providing a function
                  StringMathematica (and such) which constructs
                  a GAP-string containing a GAP-object but written
                  in Mathematica native syntax.
  gap.m       --- a loose collection of functions to show how to
                  use the Mathematica-expressions written via
                  StringMathematica plus some function to convert
                  a Mathematica-structure into GAP native syntax.

comments:
* The gap.m file is *not* implemented as a Package[] since
it has to be extended quite a lot to be useful for a
specific purpose.
* The code ToCycles and FromCycles which comes in the packages
with the Mathematica product are not very useful to compute
with permutations. New functions are provided in gap.m
* Make sure new structures do not clash with existing ones
when extending math.g for more advanced structures. My
design guideline was to output structures that are somewhat
clumsy but which do not interfere with anything existing,
for example cyc[3 e[7]^3 + e[7]^2] is an element of an
extension field --- although it would be easier to leave
out the "cyc". In a similar fashion I decided to represent
GAP-records as rec[{t1 -> v1, .., tn -> vn}] instead of
leaving away the {} or the "rec". It proved already useful
to me.
* Output of Mathematica-structures to GAP is difficult. The
strategy is: Convert the Mathematica-structure into an
output structures which prints as GAP-syntax when printed
in OutputForm[]. Note however that it will not be printed
correctly if it is output in InputForm[], for example with
X >>> outputfilename
Any suggestions how to solve the problem in a clean way?

examples:
  * Mathematica to GAP:
      <<gap.m
      s1 = rec[{"+" -> True, "-" -> False, "IsGroup" -> False}];
      s2 = {s1, s1, {1,2,3}};
      out = OpenWrite["file.g", {FormatType -> OutputForm, PageWidth -> Infinity}];
      Write[out, "x := ", formatGAP[s2], ";"];
    creates `file.g' with contents
      x := [rec('+' := true,'-' := false,'IsGroup' := false),rec('+' := true,'-' := false,'IsGroup' := false),[1,2,3]];
    If you forget to set OutputForm then the output will in fact
    contain things like Infix[], if you forget to set PageWidth to
    infinity then Mathematica will break lines an insert ">"-Characters
    to indicate continuation. This causes heavy digestive problems to GAP.
    If you forget to put a trailing ";" into the file then GAP will
    complain about a syntax error.
* GAP to Mathematica:
    Read("math.g");
    g1 := Group((1,2,3), (1,2));
    PrintToMathematica("file.m"); # empty `file.m'
    AppendTo("file.m", "g1 = ");
    AppendToMathematica("file.m", g1);
 creates `file.m' containing
   g1 = rec[{
     "isDomain"    -> True,
     "isGroup"     -> True,
     "identity"    -> perm[{}],
     "generators"  -> {perm[{{1,2,3}}], perm[{{1,2}}]},
     "operations"  -> Skeleton[151],
     "isPermGroup" -> True,
     "isFinite"    -> True,
     "1"           -> perm[{{1,2,3}}],
     "2"           -> perm[{{1,2}}]
   }]

have fun with it,
Sebastian Egner.


> < [top]